package com.changgou.search.listener;

import com.changgou.search.service.EsManageService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <dl>
 * <dd>描述: ~节点业务逻辑实现</dd>
 * <dd>创建时间：  14:42 2020/4/5</dd>
 * <dd>创建人： zz</dd>
 * <dt>版本历史: </dt>
 * <pre>
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2020/4/5      guodong       1.0        1.0 Version
 * </pre>
 * </dl>
 */

@Component
@RabbitListener(queues = "search_add_queue")
public class SkuUpListener {

    private Logger log = LoggerFactory.getLogger(SkuUpListener.class);

    @Autowired
    private EsManageService esManageService;

    @RabbitHandler
    public void receiveMsg(String spuId){
        log.info("接收到商品上架spuID: {}", spuId);
        if(StringUtils.isNotEmpty(spuId)){
            esManageService.importBySpuId(spuId);
        }
    }
}
